<#include "/common/head.html"/> 
<table id="dg"></table>
<div id="tb" style="padding:2px 5px;">
   	    <div style="text-align: left; margin:6px;">
            <a href="javascript:void(0)" class="easyui-linkbutton addBtn" iconCls="glyphicon-plus" plain="true" onclick="add()">新增</a>
          
        </div>
    </div>
<script type="text/javascript">
var datagrid = $("#dg");
var dgOptions = {
        rownumbers:true,
    	fit:true,
    	border:false,
    	striped:true,
        rownumbers:true,
    	url:'listData',
    	method:'post',
    	toolbar:'#tb',
    	pageSize:20,
    	pagination:true,
    	multiSort:true,
    	singleSelect:true,
//         queryParams: getInitParam(),
        columns: [[
				{field:'name', title:'商户名称', width:100, sortable: true,
					formatter: function(value,row,index){
	                    var url='detailpageList';
	                    var str = '<a href='+url+'?id='+row.id+'&balance='+row.balance+'&searchNumber='+row.searchNumber+'&setId='+row.setId+'&name='+value+'&serviceId='+row.serviceId+'>'+value+'</a>';
	                    return str;
	                   
	                }	
				}
		         ,{field:'username',title: '商户账号', width:100}
	           	 ,{field:'type', title: '商户类型', width:100,formatter:formatPayType}
		         ,{field:'money',title: '预存款', width:100}
	           	 ,{field:'usedMoney', title: '已用金额', width:100}
	           	,{field:'balance', title: '可用余额', width:100 }
	           	,{field:'searchNumber', title: '查询条数', width:100}
// 	           	,{field:'permissionId', title: '权限', width:100,formatter:formatPayType2}
//           	,{field:'ruleSetId', title: '所属规则集', width:112,formatter:formatRuleId}
	           	,{field:'status', title: '状态', width:100, formatter:formatStatus}//状态  0-有效  1-冻结
	           	,{field:'createTime', title: '创建时间', width:150, sortable: true}
	           ]]
	};
$(function() {

	datagrid.datagrid(dgOptions);
});


function add() {
	location.replace('addPage');
}

//var s_time = 0;
function zcurdSearch() {
	var param = zcurdGetParam();
	//if(s_time==0){
	//	datagrid.datagrid(dgOptions);
	//	s_time++;
	//}else{
		datagrid.datagrid("load", param);
	//}
}

function zcurdGetParam() {
	var param = {};
	$("#tb :input[name]").each(function(i, item) {
		if($(item).val()) {
			param[$(item).attr("name")] = $(item).val().trim();	
		}
	});
	return param;
}

function formatPayType(value,row,index){
	if(value == '0'){
		return "个体";
	}
	if(value == '1'){
		return "企业";
	}
	
}
function formatPayType2(value,row,index){

	if (row.type=='0') {
		if(value == '1'){
			return "反欺诈";
		}
		if(value == '2'){
			return "评分卡";
		}
	}
	
	if (row.type=='1') {
		if(value == '0'){
			return "权限管理";
		}
		if(value == '1'){
			return "订单管理";
		}
		if(value == '2'){
			return "管理员";
		}
	}
	
}
function formatStatus(value,row,index){

	if (value == '0') {
		return "有效";
	}
	if (value == '1') {
		return "冻结";
	}
}
</script>
<#include "/common/dialogWindow.html"/>
<#include "/common/foot.html"/>